package com.heima.article.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.heima.article.mapper.AuthorMapper;
import com.heima.article.service.AuthorService;
import com.heima.model.article.pojos.ApAuthor;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.common.enums.AppHttpCodeEnum;
import com.heima.model.wemedia.pojos.WmUser;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class AuthorServiceImpl extends ServiceImpl<AuthorMapper, ApAuthor>
        implements AuthorService {

    @Override
    public ResponseResult findByUserId(Integer id) {
        LambdaQueryWrapper<ApAuthor> lambdaQueryWrapper =new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(ApAuthor::getId,id);
        List<ApAuthor> list = list(lambdaQueryWrapper);
        if(list!=null && !list.isEmpty()){
            return ResponseResult.okResult(list.get(0));
        }
        return  ResponseResult.errorResult(AppHttpCodeEnum.DATA_NOT_EXIST);
    }
}
